home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Misc / emu / fbzx.lha / fbzx / computer.h < prev    next >
C/C++ Source or Header  |  2004-01-06  |  6KB  |  175 lines

  1. #ifndef computer_h
  2. #define computer_h
  3.  
  4. #include <SDL/SDL.h>
  5. #include <SDL/SDL_thread.h>
  6.  
  7. // #define MUT
  8.  
  9. #define OSS
  10.  
  11. extern char salir;
  12.  
  13. enum tapmodes {TAP_GUIDE, TAP_DATA, TAP_PAUSE, TAP_TRASH, TAP_STOP, TAP_PAUSE2, TZX_PURE_TONE,
  14.     TZX_SEQ_PULSES, TAP_FINAL_BIT, TAP_PAUSE3};
  15. enum taptypes {TAP_TAP, TAP_TZX};
  16.  
  17. struct computer {
  18.  
  19.   unsigned int temporal_io;
  20.  
  21.   // screen private global variables
  22.   SDL_Surface *screen;
  23.   unsigned char *screenbuffer;
  24.   unsigned int screen_width;
  25.   unsigned int translate[6144],translate2[6144];
  26.  
  27.   int contador_flash;
  28.  
  29.   unsigned int *p_translt,*p_translt2;
  30.   unsigned char *pixel; // current address
  31.   char border,flash;
  32.   int currline,currpix;
  33.  
  34.   int tstados_counter; // counts tstates leaved to the next call
  35.   int resx,resy,bpp; // screen resolutions
  36.   int init_line; // cuantity to add to the base address to start to paint
  37.   int next_line; // cuantity to add when we reach the end of line to go to next line
  38.   int first_line; // first line to start to paint
  39.   int last_line; // last line to paint
  40.   int first_pixel; // first pixel of a line to paint
  41.   int last_pixel; // last pixel of a line to paint
  42.   int pixancho,pixalto; // maximum pixel value for width and height
  43.   unsigned char screen_snow; // 0-> no emulate snow; 1-> emulate snow
  44.  
  45.   // keyboard private global variables
  46.  
  47.   unsigned char s8,s9,s10,s11,s12,s13,s14,s15;
  48.   unsigned char k8,k9,k10,k11,k12,k13,k14,k15;
  49.   unsigned char readed;
  50.  
  51.   // kempston joystick private global variables
  52.  
  53.   unsigned char js,jk;
  54.  
  55.   // sound global variables
  56.  
  57.   int tst_sample; // number of tstates per sample
  58.   int freq; // frequency for reproduction
  59.   int format; // 0: 8 bits, 1: 16 bits LSB, 2: 16 bits MSB
  60.   signed char sign; // 0: unsigned; 1: signed
  61.   int channels; // number of channels
  62.   int buffer_len; // sound buffer length (in samples)
  63.   int increment; // cuantity to add to jump to the next sample
  64.   unsigned char volume; // volume
  65.   unsigned char sample1[4]; // buffer with precalculated sample 1 (for buzzer)
  66.   unsigned char sample1b[4]; // buffer with prec. sample 1 (for AY-3-8912)
  67.   unsigned char sample0[4]; // buffer with precalculated sample 0
  68.   unsigned char sound_bit;
  69.   unsigned int tstados_counter_sound;
  70.   unsigned char *current_buffer;
  71.   unsigned char num_buff;
  72.   unsigned int sound_cuantity; // counter for the buffer
  73.   unsigned char ay_registers[16]; // registers for the AY emulation
  74.   unsigned int aych_a,aych_b,aych_c,aych_n,aych_envel; // counters for AY emulation
  75.   unsigned char ayval_a,ayval_b,ayval_c,ayval_n;
  76.   unsigned char ay_emul; // 0: no AY emulation; 1: AY emulation
  77.   unsigned char vol_a,vol_b,vol_c;
  78.   unsigned int tst_ay;
  79.   unsigned int tst_ay2;
  80.   unsigned int ay_latch;
  81.   char ay_envel_value;
  82.   unsigned char ay_envel_way;
  83.   unsigned char sound_current_value;
  84.  
  85.   // bus global variables
  86.  
  87.   unsigned char bus_counter;
  88.   unsigned char bus_value;
  89.   unsigned char issue; // 2= 48K issue 2, 3= 48K issue 3
  90.   unsigned char mode128k; // 0=48K, 1=128K, 2=+2, 3=+3
  91.   unsigned char joystick; // 0=cursor, 1=kempston, 2=sinclair1, 3=sinclair2
  92.   unsigned char port254;
  93.  
  94.  
  95.   // tape global variables
  96.  
  97.   enum tapmodes tape_current_mode;
  98.   unsigned char pause; // 1=tape stop
  99.   enum taptypes tape_file_type;
  100.   unsigned int tape_counter0;
  101.   unsigned int tape_counter1;
  102.   unsigned int tape_counter_rep;
  103.   unsigned char tape_byte;
  104.   unsigned char tape_bit;
  105.   unsigned char tape_readed;
  106.   unsigned int tape_byte_counter;
  107.   unsigned int tape_pause_at_end;
  108.   FILE *tap_file;
  109.   unsigned char tape_fast_load; // 0 normal load; 1 fast load
  110.   unsigned char current_tap[2049];
  111.   
  112.   unsigned char tape_current_bit;
  113.   unsigned int tape_block_level;
  114.   unsigned int tape_sync_level0;
  115.   unsigned int tape_sync_level1;
  116.   unsigned int tape_bit0_level;
  117.   unsigned int tape_bit1_level;
  118.   unsigned char tape_bits_at_end;
  119.   unsigned int tape_loop_counter;
  120.   long tape_loop_pos;
  121.   
  122.   unsigned char tape_write; // 0 can't write; 1 can write
  123.   
  124.   // Microdrive global variables
  125.   FILE *mdr_file;                  // Current microdrive file
  126.   unsigned char mdr_current_mdr[2049]; // current path and name for microdrive file
  127.   unsigned char mdr_active;  // 0: not installed; 1: installed
  128.   unsigned char mdr_paged;  // 0: not pagined; 1: pagined
  129.   unsigned int mdr_tapehead; // current position in the tape
  130.   unsigned int mdr_bytes;      // number of bytes read or written in this transfer
  131.   unsigned int mdr_maxbytes; // maximum number of bytes to read or write in this transfer
  132.   unsigned int mdr_gap;         // TSTATEs remaining for GAP end
  133.   unsigned int mdr_nogap;      // TSTATEs remaining for next GAP
  134.   unsigned char mdr_cartridge[137923]; // current cartridge
  135.   unsigned char mdr_drive; // current drive
  136.   byte mdr_old_STATUS; // to detect an edge in COM CLK
  137.   unsigned char mdr_modified; // if a sector is stored, this change to know that it must be stored in the file
  138.   
  139.   // OSD global variables
  140.  
  141.   unsigned char osd_text[81];
  142.   unsigned int osd_time;
  143.  
  144.   // pagination global variables
  145.  
  146.   unsigned char mport1,mport2; // ports for memory management (128K and +3)
  147.   unsigned int video_offset; // 0 for page 5, and 32768 for page 7
  148.   unsigned char *block0,*block1,*block2,*block3; // pointers for memory access (one for each 16K block).
  149.  
  150.   // public
  151.  
  152.   unsigned char memoria[196608]; // memory (12 pages of 16K each one). 4 for ROM, and 8 for RAM
  153.   unsigned char shadowrom[8192]; // space for Interface I's ROMs
  154.   unsigned char interr;
  155.   unsigned char mustlock;
  156.   unsigned char other_ret; // 0=no change; 1=memory returns RET (201)
  157.  
  158. };
  159.  
  160. void computer_init();
  161. void register_screen(SDL_Surface *);
  162. inline void show_screen(int);
  163. inline void paint_pixels(unsigned char, char, char);
  164. inline void read_keyboard();
  165. void fill_audio(void *udata,Uint8 *,int);
  166. void set_volume(unsigned char);
  167. inline void play_sound(unsigned int);
  168. inline void emulate(int);
  169. void ResetComputer();
  170. inline byte bus_empty();
  171. void set_memory_pointers();
  172. inline void play_ay();
  173.  
  174. #endif
  175.